package com.ly.system.controller.exam;

import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.R;
import com.ly.common.core.domain.TableDataInfo;
import com.ly.system.domain.exam.ExamQuestion;
import com.ly.system.domain.exam.dto.ExamAddDTO;
import com.ly.system.domain.exam.dto.ExamEditDTO;
import com.ly.system.domain.exam.dto.ExamQueryDTO;
import com.ly.system.domain.exam.dto.ExamQuestionAddDTO;
import com.ly.system.domain.exam.vo.ExamDetialVO;
import com.ly.system.domain.question.dto.QuestionAddDTO;
import com.ly.system.service.exam.IExamService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exam")
@Tag(name="竞赛管理接口")
public class ExamController extends BaseController {
//    列表 新增 编辑 发布 撤销发布 删除
    @Autowired
    private IExamService examService;

    //exam/list
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examDTO){
      return getTableDataInfo(examService.list(examDTO));
    }
    //exam/add
    @PostMapping("/add")
    public R<String> add(@RequestBody ExamAddDTO examAddDTO) {
        return R.ok(examService.add(examAddDTO));
    }

    //exam/question/add
    @PostMapping("/question/add")
    public R<Void> QuestionAdd(@RequestBody ExamQuestionAddDTO examQuestionAddDTO){
        return toR(examService.questionAdd(examQuestionAddDTO));
    }
    @DeleteMapping("/question/delete")
    public R<Void> QuestionDelete(Long examId,Long questionId){
        return toR(examService.questionDelete(examId,questionId));
    }
    //exam/detail
    @GetMapping("/detail")
    public R<ExamDetialVO> detail(Long examId){
       return R.ok( examService.detail(examId));
    }

    //exam/edit
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody ExamEditDTO examEditDTO ){
        return toR(examService.edit(examEditDTO));
    }

    //exam/delete
    @DeleteMapping("/delete")
    public R<Void> delete(Long examId){
        return toR(examService.delete(examId));
    }

    //exam/publish
    @PutMapping("/publish")
    public R<Void> publish(Long examId){
        return toR(examService.publish(examId));
    }

    //exam/cancelPublish
    @PutMapping("/cancelPublish")
    public R<Void> cancelPublish(Long examId){
        return toR(examService.cancelPublish(examId));
    }

}
